#pragma once
#ifndef NODEITEMBASE_H
#define NODEITEMBASE_H

#include<QGraphicsItem>
#include<QGraphicsTextItem>
#include<QGraphicsProxyWidget>
#include<QList>
#include<QDataStream>
#include<QtGui>

#include"types.h"
#include"node_data.h"

class NodeItemBase : public QGraphicsItem
{
public:
    NodeItemBase()=default;
    NodeItemBase(QString node_name); // ctor
    NodeItemBase(const NodeItemBase &node_item);    // copy ctor
    NodeItemBase(const NodeItemBase &&node_item);   // move ctor
    void operator=(const NodeItemBase &nodeItem);   // = ctor
    virtual ~NodeItemBase();

    int type() const override {return Type_NodeItem; }

    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
    virtual QRectF boundingRect() const override;
    virtual bool contains(const QPointF &point) const override;
    virtual double getData(){ return 0; };
    virtual void setData(){};

    void setTitle(QString title){this->text->setPlainText(title); }


public:
    QString title;
    std::shared_ptr<QColor> title_color;
    std::shared_ptr<QGraphicsTextItem> text;
    std::shared_ptr<QGraphicsProxyWidget> proxyContent; //嵌入的widget


public:
    float width = 180; // 节点大小
    float title_height = 24;
    float height = 100;
    float edge_size = 10.0;

};


class NodeItemNumberInput : public NodeItemBase{
public:
    NodeItemNumberInput();
    double getData() override;
    void setData() override;
    int type() const override {return Type_NodeItemNumber;}

public:
    std::shared_ptr<NodeDataNumberInput> node_data;
};

#endif // NODEITEMBASE_H
